class Dialog {
	constructor(ctx, hook, initNode) {
		this.ctx = ctx;
		this.hook = hook;
		this.initNode = initNode;
		this.childs = hook.$m.$reactive([]);
	}
	open(param, ...args) {
		const { ctx, hook, childs } = this;
		const { $ref, $watch } = hook.$m;
		const show = $ref(true);
		$watch(show, 'value', v => (!v) && this.close());
		childs.push(this.initNode(show, param, ...args));
	}
	close(index) {
		if(typeof index === "number"){
			this.childs.splice(index, 1);
		} else {
			this.childs.pop();
		}
	}
	closeAll() {
		this.childs.length = 0;
	}
};
export default Dialog;